package chen.web.controller.blog;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import chen.web.MyContextProvider;
import chen.web.blog.Blog;
import chen.web.blog.BlogManager;
import chen.web.user.Account;


/**
 * 网站首页，若用户已经创建了博客，首页就是其博客
 * @author admin
 *
 */
@Controller
public class HomeController {

	private @Autowired BlogManager bm;
	
	@RequestMapping(value="/", method=RequestMethod.GET)
	public String home(Model model){
		Account acc = MyContextProvider.getMyContext().getAccount();
		Blog blog = bm.getBlog(acc);
		return blog == null ? "home" : "blog";
	}
}
